package itsec1.customermanagement;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class HashUtil {

	private static MessageDigest md;

	static {
		try {
			md = MessageDigest.getInstance("SHA256");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Cannot be instantiated.
	 */
	private HashUtil() {
	}

	/**
	 * Creates a hash for the given password.
	 * 
	 * @param password
	 *            The plain-text password.
	 * @return The hashed password.
	 */
	public static byte[] encodePassword(String password) {
		return md.digest(password.getBytes());
	}

}
